local EntityFactory = class("EntityFactory")

local Hero = import(".Hero")
local Creature = import(".Creature")

local AvatarFactory = require("app.public.avatar.AvatarFactory")

function EntityFactory:ctor()
end

--[[
    create hero params
    {
        sex, --性别 [required]
        race, --种族 [required]
        class, --职业 [required]
        equips == 1 --装备
        dir = 1 or -1  -- (1: =>)  (-1: <=)
    }
--]]
function EntityFactory:newHero(params)
    local dir = params.dir

    local classID = params.classID
    local raceID = params.raceID
    local gender = params.gender
    local hairID = params.hairID
    local faceID = params.faceID
    local hairColorID = params.hairColorID
    local fashionIDs = params.fashionIDs
    local bHero = params.bHero
    
    local heroAvatarParam = {
        classID=classID,
        raceID=raceID,
        gender=gender,
        hairID = hairID,
        faceID=faceID, 
        hairColorID = hairColorID, 
        fashionIDs = fashionIDs, 
        inBattle=true,
        autoAudio=true
    }

    local armature = AvatarFactory.createHero(heroAvatarParam)
    if not armature then
        print("EntityFactory:newHero fail maskId:",maskId)
        return nil
    end
    --assert(armature,"load armature fail maskId:",maskId," weaponId:",weaponId)
    
    local hero = Hero.new({armature=armature,dir=dir,bHero = bHero})
    --hero.aniPrefix = weaponRes.ani_prefix
    hero.createParams = {classID=classID,
        raceID=raceID,
        gender=gender,
        hairID = hairID,
        faceID=faceID, 
        hairColorID = hairColorID, 
        fashionIDs = fashionIDs, 
        inBattle=true}
    --hero:setScale(0.5)
    return hero
end

--[[
create hero mercenary
{
id= 1  佣兵ID
dir = 1 or -1  -- (1: =>)  (-1: <=)
}
--]]

function EntityFactory:newCreature(params)
    local id = params.id or 1
    local dir = params.dir
    local armature  = AvatarFactory.createNpcById(id,true)
    local creature = Creature.new({armature=armature,dir=dir})
    creature.createParams = id
    return creature
end

return EntityFactory